from PIL import Image

im = Image.open("captcha2.jpg")
im = im.convert("J")
im2 = Image.new("J", im.size, 255)

im= im.convert("J")

temp = {}

for x in range(im.size[1]):
    for y in range(im.size[0]):
        pix = im.getpixel((y, x))
        temp[pix] = pix
        if pix == 220 or pix == 227:
            im2.putpixel((y,x), 0)

im2.save("output.jpg")    
